#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
#define lowbit(x) (x&(-x))
int n,m,L;
double V;
struct Car{
    int d,v,a;
} car[100001];
int P[100001];
int tr[100001];
cc_hash_table<int,int> hashe;
vector<pair<int,int>> vec;
void add(int p,int v){
    for(int i=p;i<=m;i+=lowbit(i)){
        tr[i]+=v;
    }
}
int askp(int p){
    int ans=0;
    for(int i=p;i>=1;i-=lowbit(i)){
        ans+=tr[i];
    }
    return ans;
}
int ask(int l,int r){
    return askp(r)-askp(l-1);
}
/*int turn(string s){
    for(int i=1;i<=n;++i){
        bool flag=false;
        for(int j=0;j<s.size();++j){
            if(s[j]=='0') continue;
            if(P[j+1]<car[i].d) continue;
            int s=P[j+1]-car[i].d;
            int tmp=car[i].v*car[i].v+2*car[i].a*s;
            if(tmp<0) continue;
            double vt=sqrt(tmp);
            if(vt>V){
                flag=true;
                break;
            }
        }
        if(!flag) return m;
    }
    int ans=0;
    for(int i=0;i<s.size();++i){
        if(s[i]=='1') ++ans;
    }
    return ans;
}*/
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int T;
    cin>>T;
    while(T--){
        vec.clear();
        hashe.clear();
        for(int i=1;i<=m;++i) tr[i]=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;++i) cin>>car[i].d>>car[i].v>>car[i].a;
        for(int i=1;i<=m;++i) cin>>P[i];
        sort(P+1,P+m+1);
        int cnt=0;
        for(int i=1;i<=m;++i){
            hashe[P[i]]=++cnt;
        }
        int ans1=0;
        for(int i=1;i<=n;++i){
            if(car[i].a>0){
                if(car[i].d>P[m]) continue;
                int s=P[m]-car[i].d;
                double v=sqrt(car[i].v*car[i].v+2*car[i].a*s);
                if(v>V){
                    ++ans1;
                    double time=(double)(V-car[i].v)/car[i].a;
                    int x=ceil(car[i].v*time+0.5*car[i].a*time*time+car[i].d);
                    x=min(x,P[m]);
                    int position=lower_bound(P+1,P+m+1,x)-P;
                    int pp=hashe[P[position]];
                    vec.push_back(make_pair(pp,cnt));
                }
            }
            else{
                if(car[i].d>P[m]||car[i].v<V) continue;
                int pos=lower_bound(P+1,P+m+1,car[i].d)-P;
                int s=P[pos]-car[i].d;
                int tmp=car[i].v*car[i].v+2*car[i].a*s;
                if(tmp<0) continue;
                double v=sqrt(tmp);
                if(v>V){
                    ++ans1;
                    if(car[i].a==0){
                        int position=lower_bound(P+1,P+m+1,car[i].d)-P;
                        int pp=hashe[P[position]];
                        vec.push_back(make_pair(pp,cnt));
                        continue;
                    }
                    double time=(double)(car[i].v-V)/(-car[i].a);
                    int x=car[i].v*time+0.5*car[i].a*time*time+car[i].d;
                    x=min(x,P[m]);
                    int position=lower_bound(P+1,P+m+1,x)-P;
                    int pp=hashe[P[position]];
                    vec.push_back(make_pair(1,pp));
                }
            }
        }
        int ans2=0;
        sort(vec.begin(),vec.end());
        for(int i=0;i<vec.size();++i){
            if(!ask(vec[i].first,vec[i].second)){
                add(vec[i].second,1);
            }
        }
        ans2=m-ask(1,cnt);
        for(int i=1;i<=m;++i) tr[i]=0;
        for(int i=vec.size()-1;i>=0;--i){
            if(!ask(vec[i].first,vec[i].second)){
                add(vec[i].first,1);
            }
        }
        ans2=max(ans2,m-ask(1,cnt));
        /*if(n<=10&&m<=10){
            stack<pair<int,string>> s;
            s.push(make_pair(1,""));
            while(!s.empty()){
                pair<int,string> copy=s.top();
                s.pop();
                if(copy.first==m+1){
                    ans2=max(ans2,m-turn(copy.second));
                    continue;
                }
                s.push(make_pair(copy.first+1,copy.second+'0'));
                s.push(make_pair(copy.first+1,copy.second+'1'));
            }
        }*/
        cout<<ans1<<" "<<ans2<<"\n";
    }
}